#include "../include/p_key.h"
#define KEY_PATH ""

using namespace __public_key;
using std::string;

// misc function
bool priv_key_retr() {
#ifndef KEY_PATH
	DBG_PRNT(DBG)("key path unspecified. abort.\n");
	return false;
#else
	char key_path[64];
	strcpy(key_path, KEY_PATH); // preserving private key path

	FILE * fp = fopen(key_path, "r");
	if (fp == NULL) {
		// file did not open
		DBG_PRNT(DBG)("unable to open file.\n");
		fclose(fp);
		return false;
	} else {
		// file open
		bool ret = false;
		unsigned key_buf;

		int key_leng = fread(&key_buf, sizeof(unsigned), 1, fp);
		if (key_leng == 0) {
			// nothing read
			DBG_PRNT(DBG)("nothing read.\n");
		} else if (key_leng != sizeof(unsigned)) {
			// read size wrong
			DBG_PRNT(DBG)("size wrong. expected to read %d byte. %d byte read instead.\n", sizeof(unsigned), key_leng);
		} else {
			// everything checks out
			priv_key = key_buf;
			DBG_PRNT(DBG)("key get. %u\n", priv_key);
			ret = true;
		}

		// close up
		fclose(fp);

		return ret;
	}
#endif
}

// encryptor

bool
encryptor::encrypt(const char * msg, char * result) {
}

// decryptor

bool
decryptor::decrypt(const char * msg, char * result) {
}